/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.create;

import br.com.deployment.daoImpl.OrganDAOImpl;
import br.com.deployment.entities.City;
import br.com.deployment.entities.Organ;
import br.com.deployment.utils.Msg;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author luciano
 */
@ManagedBean
@ViewScoped
public class ManagerCreateOrgan {
    
    @EJB
    OrganDAOImpl organService;
    
    private Organ organ;

    private City city;
    
    public ManagerCreateOrgan() {
        this.organ = new Organ();
    }
    
    public void save(){
      organ.setCity(this.city);
      organService.save(organ);
      Msg.messagemInfo("Orgão Salvo com Sucesso.");
      this.city = new City();
      this.organ = new Organ();
    }

    public List<Organ> autocomplete(String query){
        return organService.findByName(query);
    }
    
    public City getCity() {
        return city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public Organ getOrgan() {
        return organ;
    }

    public void setOrgan(Organ organ) {
        this.organ = organ;
    }
    
    
}
